﻿/****************************************************************************
Copyright (c) 2014-2015 凌惊雪 微信:Lingjingxue 邮箱:lingjingxue@sina.com QQ:271487457

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

using UtilPublic.ServerLoger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;
using UtilLib;
using ServerBase.Service;
using System.Text;
using ServerBase.Protocol;
using UtilPublic.Files;

namespace ServerBase.IniFile
{
    /// <summary>
    /// INI配置文件
    /// </summary>
    public static partial class IniConf
    {
        // 配置文件目录
        public const string eIniConfPath = @"IniFiles/";

        // 初始化配置
        public static bool InitIniConf()
        {
            bool result = true;

            //if (result) { result = IniRead.ReadClass(文件路径(nameof(ConfSwitch)), 项目名称ServerRunMode(), ref ConfSwitch); }

            if (result) { result = IniRead.ReadClass(文件路径(nameof(ConfGm)), 项目名称ServerPlatform(), ref ConfGm); }

            return result;
        }

        public static string 文件路径(string name)
        {
            return $"{eIniConfPath}{name}.ini";
        }
        public static string 项目名称ServerRunMode()
        {
            return BaseServerInfo.ServerRunMode.ToString();
        }
        public static string 项目名称ServerPlatform()
        {
            return $"{(int)BaseServerInfo.ServerPlatform}";
        }

        //public class CConfigSwitch
        //{
        //    [Desc("数据库状态")]
        //    public bool MysqlState = false;
        //    [Desc("Telnet端口")]
        //    public int TelnetServerPort = 8888;
        //    [Desc("Http端口")]
        //    public int HttpServerPort = 8080;
        //    [Desc("限制登录")]
        //    public bool RestrictLogin = false;
        //    [Desc("单服限制人数")]
        //    public int RestrictOnline = 2000;
        //    [Desc("版本验证码")]
        //    public long VersionPin = 1234567890;
        //}
        //public static CConfigSwitch ConfSwitch = new CConfigSwitch();


        public class CConfigGm
        {
            public List<string> ListGmList = new List<string>();
        }
        public static CConfigGm ConfGm = new CConfigGm();
    }
}